package com.pw.study.mr.letter;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class PartitionerByLetter extends Partitioner<Text, IntWritable> {

    @Override
    public int getPartition(Text text, IntWritable intWritable, int i) {
        int num = text.toString().toLowerCase().charAt(0);
        //a-p97 -> 112
        //q-z113 -> 122
        if (num >= 97 && num <= 112) {
            return 0;
        } else {
            return 1;
        }

    }
}
